package com.clementheliou.cheliou.dal.model.photo.builder;

import com.clementheliou.cheliou.dal.model.member.enumeration.MemberLocale;
import com.clementheliou.cheliou.dal.model.photo.AuthorsNote;
import com.clementheliou.cheliou.dal.model.photo.Photo;
import com.clementheliou.cheliou.util.builder.ObjectBuilder;

/**
 * Builder used to get {@link AuthorsNote} instances for test purpose. It must only be used through
 * one of its static factory methods.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link AuthorsNote};
 * @see {@link ObjectBuilder}.
 * @since 1.0
 */
public class AuthorsNoteBuilder extends ObjectBuilder<AuthorsNote> {

	/**
	 * Private default constructor.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private AuthorsNoteBuilder() {
		super();
	}

	/**
	 * Creates a default {@link AuthorsNote} mock that should never be persisted.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @return the builder instance after this action.
	 * @since 1.0
	 */
	public AuthorsNoteBuilder createDefaultAuthorsNoteMock() {
		setInstance(createInstance(new Photo()));
		return this;
	}

	/**
	 * Static factory method used to get a builder instance for a {@link AuthorsNote} object that
	 * must not be persistent. It's mostly used in tests not having a real data access.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @return the builder instance to be used.
	 * @since 1.0
	 */
	public static AuthorsNoteBuilder withNoDependencies() {
		return new AuthorsNoteBuilder();
	}

	/**
	 * Creates a {@link AuthorsNote} instance with default values for the given photo. Created data
	 * have a functional sense.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param annotatedPhoto the photo the note is related to.
	 * @return the built instance.
	 * @since 1.0
	 */
	private AuthorsNote createInstance(final Photo annotatedPhoto) {
		final AuthorsNote defaultInstance = new AuthorsNote();

		defaultInstance.setAnnotatedPhoto(annotatedPhoto);
		defaultInstance.setContent("noteContent");
		defaultInstance.setLocale(MemberLocale.FRANCAIS);

		return defaultInstance;
	}
}
